<?php

class Student_IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

   public function indexAction()
    {
       $this->view->title = "Calculate GPA";
       $this->view->headTitle($this->view->title, 'PREPEND');

       $form = new Student_Form_guestGPAform();
        $this->view->form = $form;

        if ($this->getRequest()->isPost()){
    		$formData = $this->getRequest()->getPost();
    		if($form->isValid($formData))
                        {
    			$gr1 = $form->getValue('grade1');
                        $cr1 = $form->getValue('credits1');
                        $gr2 = $form->getValue('grade2');
                        $cr2 = $form->getValue('credits2');
                        $gr3 = $form->getValue('grade3');
                        $cr3 = $form->getValue('credits3');
                        $gr4 = $form->getValue('grade4');
                        $cr4 = $form->getValue('credits4');
                        $gr5 = $form->getValue('grade5');
                        $cr5 = $form->getValue('credits5');
                        $gr6 = $form->getValue('grade6');
                        $cr6 = $form->getValue('credits6');
                        $gr7 = $form->getValue('grade7');
                        $cr7 = $form->getValue('credits7');
                        $gr8 = $form->getValue('grade8');
                        $cr8 = $form->getValue('credits8');


       $GPA= new Student_Model_DbTable_guestGPA();
       $getGPA = $GPA->gpaCalc($gr1, $cr1, $gr2, $cr2, $gr3, $cr3, $gr4, $cr4, $gr5, $cr5, $gr6, $cr6, $gr7, $cr7, $gr8, $cr8);
       $this->view->message = "Your GPA is $getGPA";
       }
       else
                    {
    			$form->populate($formData);
                    }


              }
   }

   public function welcomeAction(){

       $this->view->title = "<b>Welcome to the Student Module. Following tab options will help you get started... </b>";
       $this->view->headTitle($this->view->title, 'PREPEND');
       $id = $this->_getParam('id');
       $this->id = $id;

   }
}

?>
